/**
 * Created with JetBrains WebStorm.
 * User: tbanana
 * Date: 13-6-19
 * Time: 下午2:53
 * To change this template use File | Settings | File Templates.
 */

    // 循环获取
    setInterval(function(){getNoticeList()}, 6000); // break here

    // 获取消息
    function getNoticeList(){
        var getUrl = "http://localhost:8080/zone/index.php?/test/get";
        var para = {
            'accountID':2
        } ;
        $.post(getUrl,para, function(data){
            if(data.status === true){
                var notification = webkitNotifications.createNotification(
                    'http://img3.douban.com/view/photo/photo/public/p1663070822.jpg',
                    'Hello!',  // notification title
                    data.msg  // notification body text
                );
                notification.show();
            }
        },'json');

    }

chrome.omnibox.onInputChanged.addListener(
    function(text, suggest) {
        console.log('inputChanged: ' + text);
        suggest([
            {content: text + " one", description: "the first one"},
            {content: text + " number two", description: "the second entry"}
        ]);
    });

// This event is fired with the user accepts the input in the omnibox.
chrome.omnibox.onInputEntered.addListener(
    function(text) {
        console.log('inputEntered: ' + text);
        alert('You just typed "' + text + '"');
    });

// TODO:暂时弃用，应该可以封装的很好的 ...
var MyNotice = (function () {
    var notice = {};
    var _config  = {
        "url":"http://localhost:8080/zone/index.php?/test/get",
        "userImg":"http://img3.douban.com/view/photo/photo/public/p1663070822.jpg",
        "title":"通知内容"
    };

    function privateAddTopic(data) {
        // 这里是内部处理代码
    }

    notice.Name = "www";
    notice.getNoticeList = function (accountID) {
        var para = {
            'accountID':accountID
        } ;
        $.post(_config.url,para, function(data){
            if(data.status === true){
                var notification = webkitNotifications.createNotification(
                    _config.userImg,
                    _config.title,  // notification title
                    data.msg  // notification body text
                );
                notification.show();
            }
        },'json');;
    };


    return notice;
} ());

